﻿#ifndef NSSHARE_SYS_MOUSE_EVENT_H_
#define NSSHARE_SYS_MOUSE_EVENT_H_

#include <stdint.h>

#include "../utils/bitwise_enum.h"

namespace nsshare
{
namespace sys
{
    
class MouseEvent
{
public:
    enum MouseEventType
    {
        kMouseMove = 1,     //鼠标移动的 
        kMouseDown,         //鼠标按下
        kMouseUp,           //鼠标抬起
        kMouseClick,        //鼠标单击
        kMouseDoubleClick,  //鼠标双击
        kMouseWheel,        //鼠标滚轮
        kMouseEnter,        //进入窗口
        kMouseLeave,        //离开窗口
        kMouseHover,        //鼠标悬停
    };

    enum _MouseButtons
    {
        kLeft = 0x100000,
        kRight = 0x200000,
        kMiddle = 0x400000,
        kXButton1 = 0x800000,
        kXButton2 = 0x1000000,
    };

    typedef utils::BitwiseEnum<_MouseButtons> MouseButtons;

public:
    MouseEvent(int16_t x, int16_t y)
    {
        type_ = static_cast<MouseEventType>(0);
        x_ = x;
        y_ = y;
        dx_ = dy_ = 0;
    }

    MouseEvent( MouseEventType type,
        int16_t x, int16_t y)
    {
        type_ = type;
        x_ = x;
        y_ = y;
        dx_ = dy_ = 0;
    }

    MouseEvent( MouseEventType type,
        int16_t x, int16_t y, MouseButtons button)
    {
        type_ = type;
        x_ = x;
        y_ = y;
        button_ = button;
        dx_ = dy_ = 0;
    }

    //==============================================
    MouseEvent(void)
    {
        type_ = static_cast<MouseEventType>(0);
        x_ = y_ = 0;
        dx_ = dy_ = 0;
    }



    void set_type(const MouseEventType t){type_ = t;}
    void set_x(int16_t x) {x_ = x;}
    void set_y(int16_t y) {y_ = y;}
    void set_dx(int16_t delta) {dx_ = delta;}
    void set_dy(int16_t delta) {dy_ = delta;}
    void set_button(const MouseButtons button){ button_ = button; }
    void set_state(const MouseButtons state){ state_ = state;}
    //================================================== 
    MouseEventType type() const
    {
        return type_;
    }

    int16_t x() const
    {
        return x_;
    }

    int16_t y() const
    {
        return y_;
    }

    int16_t dx() const
    {
        return dx_;
    }

    int16_t dy() const
    {
        return dy_;
    }

    MouseButtons button() const
    {
        return button_;
    }

    MouseButtons state() const
    {
        return state_;
    }
private:
    MouseEventType type_;
    MouseButtons button_;
    MouseButtons state_;
    int16_t x_;
    int16_t y_;
    int16_t dx_;
    int16_t dy_;
};

}
}

#endif
